package com.thitech.sif.context;

import com.thitech.sif.Constant;

/**
 * Web Service上下文请求对象
 * 
 * @author shisheng.lian
 * 
 */
public class WSContext extends AbsContext {

	/**
	 * 通信协议
	 */
	private String protocol = "http";

	/**
	 * The WSDD service name defaults to the port name.
	 */
	private String portName;

	/**
	 * Axis1生成的Locator类全限定名
	 */
	private String locatorClass;

	/**
	 * WSDL除主机名（IP）、端口外的URI串
	 */
	private String queryString;

	@Override
	public String getServiceType() {
		return Constant.SERVICE_TYPE_WS;
	}

	public String getProtocol() {
		return protocol;
	}

	public void setProtocol(String protocol) {
		this.protocol = protocol;
	}

	public String getPortName() {
		return portName;
	}

	public void setPortName(String portName) {
		this.portName = portName;
	}

	public String getLocatorClass() {
		return locatorClass;
	}

	public void setLocatorClass(String locatorClass) {
		this.locatorClass = locatorClass;
	}

	public String getQueryString() {
		return queryString;
	}

	public void setQueryString(String queryString) {
		this.queryString = queryString;
	}

	/**
	 * 获取wsdl地址
	 * 
	 * @return
	 */
	public String getWSDLLocation() {
		StringBuilder sb = new StringBuilder();
		sb.append(getProtocol()).append("://").append(getHost());
		if (-1 != getPort()) {
			sb.append(":").append(getPort());
		}
		sb.append("/").append(getQueryString());
		return sb.toString();
	}
}
